
#ifndef _ascendancy_galaxy_render_
#define _ascendancy_galaxy_render_

#include <QtOpenGL>
#include <QImage>
#include <QTimeLine>
#include <QFont>
#include <iostream>

#include <stdio.h>
#include <stdlib.h>

#include "game_core.h"
#include "solar_system.h"

#define GAL_RENDER_SOL_BIG_SIZE	7
#define GAL_RENDER_SOL_MID_SIZE	6
#define GAL_RENDER_SOL_SMA_SIZE	4

//#define GAL_RENDER_NO_SYS_TO_DISPLAY	-1

#define GAL_RENDER_TEXT_RIGHT_SPACE	15
#define GAL_RENDER_TEXT_DOWN_SPACE	10

#define GAL_RENDER_PICKING_MODE_ON	true
#define GAL_RENDER_PICKING_MODE_OFF	false
#define GAL_RENDER_NO_SYS_TO_DISPLAY	-1

#define GAL_RENDER_BUFSIZE		512

class		GalaxyRender : public QGLWidget
{
  Q_OBJECT

public:

  GalaxyRender();
  ~GalaxyRender();

  void		setParent(QWidget *parent);
  void		init(GameCore	*gameCore);

  QSize		sizeHint() const;
  QSize		minimumSizeHint() const;
  
  void		rotateLeft();
  void		rotateRight();
  void		rotateUp();
  void		rotateDown();
  void		zoomIn();
  void		zoomOut();
  void		resetView();
  void		showLinks(int state);

protected:

  GLuint	selectBuf[GAL_RENDER_BUFSIZE];
  int		xToPick;
  int		yToPick;
  bool		pickingMode;
  int		windowH;
  int		windowW;
  GLfloat	ratio;

  void		mouseMoveEvent (QMouseEvent *event);

  void		initializeGL();
  void		paintGL();
  void		resizeGL(int w, int h);

private:

  int		sysToPrint;
  int		vortexToPrint;
  
  bool		printLinks;

  QWidget	*parent;
  GameCore	*gameCore;
  
  float		xRot;
  float		yRot;
  float		zoom;

  void		startPicking(int x, int y);
  int		stopPicking(int level);
  void		showSystemInfo(int system);
  void		drawVortex();
};


#endif
